# $Id: PKGBUILD 85407 2013-03-01 10:39:40Z andrea $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>

pkgname=qtspim
pkgver=9.1.7
pkgrel=2
pkgdesc="New user interface for spim, a MIPS simulator."
arch=('i686' 'x86_64')
url="http://spimsimulator.sourceforge.net/"
license=('BSD')
depends=('qt4')
makedepends=('subversion')

__svntrunk="https://spimsimulator.svn.sourceforge.net/svnroot/spimsimulator"
__svnmod=('QtSpim' 'CPU' 'Documentation' 'Setup')
__svnrev=598

build() {
  cd "$srcdir"
  msg "Connecting to SVN server...."

  for i in "${__svnmod[@]}"; do
    if [[ -d "$i/.svn" ]]; then
      (cd "$i" && svn up -r "$__svnrev")
    else
      svn co "$__svntrunk/$i" --config-dir ./ -r "$__svnrev" "$i"
    fi
  done

  msg "SVN checkout done or server timeout"
  msg "Starting build..."

  rm -rf "$srcdir/build"
  mkdir "$srcdir/build"
  for i in "${__svnmod[@]}"; do
    cp -r "$srcdir/$i" "$srcdir/build"
  done
  cd "$srcdir/build/QtSpim"

  qmake
  make
}

package() {
  cd "$srcdir/build/QtSpim"

  install -Dm755 QtSpim "$pkgdir/usr/bin/qtspim"

  install -dm755 "$pkgdir/usr/share/qtspim"
  cp -r help "$pkgdir/usr/share/qtspim"
  rm -rf "$pkgdir/usr/share/qtspim/help/.svn"

  cd "$srcdir/build"

  install -Dm644 Documentation/spim.man "$pkgdir/usr/share/man/man1/qtspim.1"
  install -Dm644 Setup/qtspim_debian_deployment/qtspim.desktop \
    "$pkgdir/usr/share/applications/qtspim.desktop"
  install -Dm644 Setup/qtspim_debian_deployment/copyright \
    "$pkgdir/usr/share/licenses/$pkgname/copyright"
  install -Dm644 Setup/NewIcon48x48.png "$pkgdir/usr/share/qtspim/qtspim.png"
}

# vim:set ts=2 sw=2 et:
